//
//  SMSRequestProvider.m
//  SulitLoan
//
//  Created by 虞嘉伟 on 2025/2/26.
//  
  

#import "LocationRequestProvider.h"
#import "LocationRequest.h"


@implementation TrackLocationModel
@end




@implementation LocationRequestProvider

+ (void)requestTrackWithLocation:(TrackLocationModel *)model success:(void(^)(NSDictionary *dict))success failure:(void(^)(YTKRequest *request))failure {
    LocationRequest *request = [LocationRequest new];
    request.witticisms = model.countryCode;
    request.happiest = model.country;
    request.paralyzed = model.province;
    request.portion = model.city;
    request.nicknames = model.street;
#ifdef DEBUG
    request.witticisms = @"CN";
    request.happiest = @"China";
    request.paralyzed = @"北京市";
    request.portion = @"北京市";
    request.nicknames = @"天安门广场";
#endif
    [request startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        NSDictionary *dict = request.responseObject;
        if (![dict isKindOfClass:NSDictionary.class]) {
            !failure ?: failure(request);
            return;
        }
        if ([dict[@"weeps"] intValue] == 0) {
            // 成功
            !success ?: success(dict[@"bounding"]);
        } else {
            !failure ?: failure(request);
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        !failure ?: failure(request);
    }];
}



@end
